<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>configurationObjectPattern</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

<script>
$(document).ready(function () {
	
	var personContainer = {
		person: {
			username: null,
			first: null,
			last: null
		},
		persons: null,
		addPerson: function (conf) {
			if(!persons) {
				persons = [];
			}
			var person = {};
			person.username = conf.username;
			person.first = conf.first;
			person.last = conf.last;
			persons.push(person);
			return persons;
		}
	};
	
	var conf1 = {
		username: "batman",
		first: "Bruce",
		last: "Wayne"
	};
	
	var conf2 = {
		username: "whitebear",
		first: "Seunghyeon",
		last: "Park"
	};
	
	var conf3 = {
		username: "byeonely",
		first: "Youngmin",
		last: "Byeon"
	};
	
	var persons = personContainer.addPerson(conf1);
	persons = personContainer.addPerson(conf2);
	persons = personContainer.addPerson(conf3);
	
	var i = 0,
		max;
	
	for ( var i = 0, max = persons.length; i < max; i++) {
		console.log(persons[i].username);
	}
	console.log(max);
	
});

</script>

</head>
    <body>
	    <h3>설정 객체 패턴</h3>
    </body>
</html>